/**
 * GTPair.h
 *
 * The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License");
 * you may not use this file except in compliance with the License. You may obtain a copy of the License 
 * at http://www.mozilla.org/MPL/
 * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
 * either express or implied. See the License for the specific language governing rights and limitations 
 * under the License.
 *
 * The Original Code is gcast-toolbox4iphone.
 *
 * The Initial Developers of the Original Code is Giannandrea Castaldi.
 */
#import "GTPair.h"

@interface GTPair ()
@property(nonatomic,retain,readwrite) id firstObject;
@property(nonatomic,retain,readwrite) id secondObject;
@end

@implementation GTPair
@synthesize firstObject, secondObject;

+ (id)pairWithFirst:(id)aFirstObject second:(id)aSecondObject {
  return [[[GTPair alloc] initWithFirst:aFirstObject second:aSecondObject] autorelease];
}

- (id)initWithFirst:(id)aFirstObject second:(id)aSecondObject {
  if ((self = [super init])) {
    self.firstObject = aFirstObject;
    self.secondObject = aSecondObject;
  }
  return self;
}

- (void)dealloc {
  [firstObject release];
  [secondObject release];
  [super dealloc];
}

- (BOOL)isEqual:(id)object {
  BOOL result = FALSE;
  if (object == self) {
    result = TRUE;
  }
  else if (object && [object isKindOfClass:[self class]]) {
    result = ([self.firstObject isEqual:[object firstObject]]
              && [self.secondObject isEqual:[object secondObject]]);
  }
  return result;
}

- (NSUInteger)hash {
	return [self.firstObject hash] + [self.secondObject hash];
}

@end
